package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.CategoryPageQueryDTO;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.*;

//分类表分页查询
@Mapper
public interface CategoryMapper {
    //分类表分页查询
    Page<Category> page(CategoryPageQueryDTO categoryPageQueryDTO);

    //分类表修改操作
    @AutoFill(value = OperationType.UPDATE)
    void update(Category category);

    //启用或禁用分类
    @Update("update category set status=#{status} where id=#{id}")
    void setstatus(Integer status, Long id);

    //新增分类
    @AutoFill(value = OperationType.INSERT)
    @Insert("insert into category(type, name, sort, status, create_time, update_time, create_user, update_user) " +
            "values (#{type},#{name},#{sort},#{status},#{createTime},#{updateTime},#{createUser},#{updateUser})")
    void addCategory(Category category);

    //删除分类
    @Delete("delete from category where id=#{id}")
    void delete(Long id);

    //根据类型查询分类
    Category[] checkList(Integer type);
}
